TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { NextResponse } from 'next/server';2import { z } from 'zod';3import { chooseCandidate } from '@/lib/ai/scanner';4import { clientIpHash, currentUserId, getAnonId } from '@/lib/ai/request';56export const runtime = 'nodejs';78export async function POST(req: Request, ctx: { params: Promise<{ id: string }> }) {9 const { id } = await ctx.params;10 const body = z.object({ assetId: z.string().nullable() }).safeParse(await req.json().catch(() => ({})));11 if (!body.success || !/^scan_[a-z0-9]+$/.test(id)) return NextResponse.json({ error: 'Invalid request' }, { status: 400 });12 const [userId, anonId, ipHash] = await Promise.all([currentUserId(), getAnonId(false), clientIpHash()]);13 const ok = await chooseCandidate(id, body.data.assetId, { userId, anonId, ipHash });14 if (!ok) return NextResponse.json({ error: 'Not found' }, { status: 404 });15 return NextResponse.json({ ok: true });16}17